package com.jlf.core.server;

import com.jlf.core.domain._SimpleDO;
import com.jlf.core.mp.persistence._SimplePersistence;
import com.jlf.core.server.entity.*;

import java.io.Serializable;

/**
 * 封装的内部服务
 *
 * @author wujr
 * 2023/7/5
 * @version 1.0
 * 【变更历史】
 * [wujr 2023/7/5 1.0 新增]
 */
public interface  _SimpleServer<T extends _SimpleDO<T>> {

    Class<T> domainClass();
    String name();
    <P extends _SimplePersistence<T>> P persistence();

    void preAdd(T record) throws Exception;
    void preAdd(AddRecordWrapper<T> wrapper) throws Exception;
    T add(T record) throws Exception;

    void add(AddRecordWrapper<T> record) throws Exception;

    void preEdit(EditRecordWrapper<T> wrapper) throws Exception;
    void preEdit(T original, T record) throws Exception;
    T edit(T original, T record) throws Exception;
    void edit(EditRecordWrapper<T> wrapper) throws Exception;
    void preDelete(T record) throws Exception;
    void preDelete(DeleteRecordWrapper<T> wrapper) throws Exception;
    T delete(T record) throws Exception;
    void delete(DeleteRecordWrapper<T> wrapper) throws Exception;
    ListWrapper<T> query(Q<T> input, Integer pageNo, Integer pageSize);

    /**
     * 根据id加载模型对象
     * @param id 对象id
     * @return 模型对象
     */
    T getById(Serializable id);
}
